home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 23
/
Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso
/
Aminet
/
disk
/
misc
/
TransADF.lha
/
Source
/
errors.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-11-30
|
4KB
|
184 lines
#include <exec/types.h>
#include <exec/errors.h>
#include <devices/trackdisk.h>
#include <dos/dos.h>
#include <clib/dos_protos.h>
#include "errors.h"
#include "main.h"
#include "zlib.h"
/*
** Output a DOS error value, as returned by IoErr(), as a text string
** to StdErr.
*/
void reportDOSError (LONG DOSError)
{
char ErrorString[80];
if (Fault (DOSError, "DOS Error", ErrorString, 79))
FPrintf (StdErr, "%s.\n", ErrorString);
else
FPrintf (StdErr, "DOS Error: %ld.\n", DOSError);
}
/*
** Output an IO Error, as returned by OpenDevice()/DoIO(), as a text
** string to stderr.
*/
void reportIOError (BYTE IOError)
{
STRPTR ErrStr;
switch (IOError) {
case IOERR_OPENFAIL:
ErrStr = "Open Failure";
break;
case IOERR_ABORTED:
ErrStr = "Aborted";
break;
case IOERR_NOCMD:
ErrStr = "No Command";
break;
case IOERR_BADLENGTH:
ErrStr = "Bad Length";
break;
case IOERR_BADADDRESS:
ErrStr = "Bad Address";
break;
case IOERR_UNITBUSY:
ErrStr = "Unit Busy";
break;
case IOERR_SELFTEST:
ErrStr = "Self Test Failure";
break;
default:
ErrStr = NULL;
}
FPuts (StdErr, "IO Error: ");
if (ErrStr)
FPuts (StdErr, ErrStr);
else
FPrintf (StdErr, "Unknown (%ld)", IOError);
FPuts (StdErr, ".\n");
}
/*
** Output a TrackDisk IO Error, as returned by OpenDevice()/DoIO(),
** as a text string to stderr.
*/
void reportTDError (BYTE TDError)
{
STRPTR ErrStr;
/* Check to see if this is a `standard' error */
if (TDError < 0)
{
reportIOError (TDError);
return;
}
switch (TDError) {
case TDERR_NotSpecified:
ErrStr = "Not Specified";
break;
case TDERR_NoSecHdr:
ErrStr = "No Sector Header";
break;
case TDERR_BadSecPreamble:
ErrStr = "Bad Sector Preamble";
break;
case TDERR_BadSecID:
ErrStr = "Bad Sector ID";
break;
case TDERR_BadHdrSum:
ErrStr = "Bad Header Checksum";
break;
case TDERR_BadSecSum:
ErrStr = "Bad Sector Checksum";
break;
case TDERR_TooFewSecs:
ErrStr = "Too Few Sectors";
break;
case TDERR_BadSecHdr:
ErrStr = "Bad Sector Header";
break;
case TDERR_WriteProt:
ErrStr = "Write Protected";
break;
case TDERR_DiskChanged:
ErrStr = "Disk Changed";
break;
case TDERR_SeekError:
ErrStr = "Seek Error";
break;
case TDERR_NoMem:
ErrStr = "No Memory";
break;
case TDERR_BadUnitNum:
ErrStr = "Bad Unit Number";
break;
case TDERR_BadDriveType:
ErrStr = "Bad Drive Type";
break;
case TDERR_DriveInUse:
ErrStr = "Drive In Use";
break;
case TDERR_PostReset:
ErrStr = "Post Reset";
break;
default:
ErrStr = NULL;
}
FPuts (StdErr, "TrackDisk Error: ");
if (ErrStr)
FPuts (StdErr, ErrStr);
else
FPrintf (StdErr, "Unknown (%ld)", TDError);
FPuts (StdErr, ".\n");
}
/*
** Output a Zlib error as a test string.
*/
void reportZLibError (LONG ZLibError)
{
STRPTR ErrStr;
switch (ZLibError) {
case Z_ERRNO:
ErrStr = "Error Number";
break;
case Z_STREAM_ERROR:
ErrStr = "Stream Error";
break;
case Z_DATA_ERROR:
ErrStr = "Data Error";
break;
case Z_MEM_ERROR:
ErrStr = "Memory Error";
break;
case Z_BUF_ERROR:
ErrStr = "Buffer Error";
break;
case Z_VERSION_ERROR:
ErrStr = "Version Error";
break;
default:
ErrStr = NULL;
}
FPuts (StdErr, "ZLib Error: ");
if (ErrStr)
FPuts (StdErr, ErrStr);
else
FPrintf (StdErr, "Unknown (%ld)", ZLibError);
FPuts (StdErr, ".\n");
}